/**
 * store.js
 * @authors 杨兴洲（of2502）
 * @date    2017/5/22 0022 18:05
 * @version 1.0
 * @last-modify  杨兴洲（of2502）
 */

import {Store} from 'iflux2';
import {fromJS} from 'immutable';
import AccountActor from './bind/actor/user-actor.js';
import * as types from './bind/constants/actionTypes.js'
import WebApi from './bind/webapi.js';
export default class AppStore extends Store {
    bindActor() {
        return [
            new AccountActor
        ]
    }

    fetchUserInfo = async () => {
        const result = await WebApi.fetchUserInfo();
        // console.log("公众号信息", result);
        this.dispatch(types.FETCH_USER_INFO, fromJS(result));
        return result;
    };

    fetchAuthUrl = async () => {
        const result = await WebApi.fetchAuthUrl();
        // console.log("授权链接", result);
        this.dispatch(types.FETCH_AUTH_URL, result.url);
        return result;
    };
}